﻿// JavaScript Document
function check() {
    var sel_gd = document.getElementById("Order_sel_gd");
    var txt_nums = document.getElementById("Order_txt_nums");
    var txt_name = document.getElementById("Order_txt_name");
    var txt_addr = document.getElementById("Order_txt_addr");
    var txt_tel = document.getElementById("Order_txt_tel");
    var txt_mob = document.getElementById("Order_txt_mob");
    var txt_email = document.getElementById("Order_txt_email");
    var cltLocationSelect1_ddlProvince = document.getElementById("Order_province");
    var cltLocationSelect1_ddlCity = document.getElementById("Order_city");

    var txt_zip = document.getElementById("Order_txt_zip");
    var WorkPlaceArea = document.getElementById("Order_WorkPlaceArea");
    var WorkPlaceCity = document.getElementById("Order_WorkPlaceCity");
    var txt_bzxx = document.getElementById("Order_txt_bzxx");

    if (sel_gd.value == "0") {
        alert("请选择订购的优惠套餐");
        sel_gd.focus();
        return false;
    }
    if (txt_nums.value == "") {
        alert("请输入订购数量");
        txt_nums.focus();
        return false;
    }
    if (isNaN(txt_nums.value)) {
        alert("输入的订购数量必须为数字");
        txt_nums.focus();
        return false;
    }
    if (txt_name.value == "" || txt_name.value.length <2) {
        alert("请输入正确的收货人姓名");
        txt_name.focus();
        return false;
    }

    if (!checkChinese(txt_name.value)) {
        alert("请输入正确的收货人姓名");
        txt_name.focus();
        return false;
    }

    checkChinese

    if (txt_addr.value == "" || txt_addr.value.length < 4) {
        alert("请输入正确的收货地址");
        txt_addr.focus();
        return false;
    }

//    if(txt_tel.value==""){
//    alert("请输入联系电话");
//    txt_tel.focus();
//    return false;
//    }
//		

//    var f = /^[_.0-9a-z-]+-([0-9a-z][0-9a-z-])+[0-9]{4,8}$/; 
//    if(!f.exec(txt_tel.value)){
//    alert("请输入正确的电话号码");
//    txt_tel.focus();
//    return false;
//    }		

    if (txt_mob.value == "") {
        alert("请输入手机号码");
        txt_mob.focus();
        return false;
    }

    if(!(/^0?1[0,1,3,5,6,8,9]\d{9}$/.test(txt_mob.value))){ 
    alert("请输入正确的手机号码");
    txt_mob.focus();
    return false;	
    }

//    if (txt_email.value == "") {
//        alert("请输入电子邮箱");
//        txt_email.focus();
//        return false;
//    }
//    if (!chkEmail(txt_email.value)) {
//        alert('请输入有效的邮箱!');
//        txt_email.focus();
//        return false;
//    }
    if (cltLocationSelect1_ddlProvince.value == "") {
        alert("请选择您所在的省份");
        cltLocationSelect1_ddlProvince.focus();
        return false;
    }
    if (cltLocationSelect1_ddlCity.value == "") {
        alert("请选择您所在的城市");
        cltLocationSelect1_ddlCity.focus();
        return false;
    }


//    if (txt_zip.value == "") {
//        alert("请输入邮政编码");
//        txt_zip.focus();
//        return false;
//    }

//    var y = /^\d{6}$/;
//    if (!y.exec(txt_zip.value)) {
//        alert("邮编号码格式不正确");
//        txt_zip.focus();
//        return false;
//    }



//    if (txt_bzxx.value == "") {
//        alert("请输入订购留言");
//        txt_bzxx.focus();
//        return false;
//    }
}

function cha() {
    var txtMessageName = document.getElementById("Reviews_txtCustomerName");
    var txt_MessageBox = document.getElementById("Reviews_txtContent");
    var txtVail = document.getElementById("Reviews_txtVail");
    if (txtMessageName.value == "") {
        alert("请输入您的姓名");
        txtMessageName.focus();
        return false;
    }
    if (txt_MessageBox.value == "") {
        alert("请输入留言内容");
        txt_MessageBox.focus();
        return false;
    }
    if (txtVail.value == "") {
        alert("请输入验证码");
        txtVail.focus();
        return false;
    }
}

function checkChinese(str) { var re = /[^\u4e00-\u9fa5]/; if (re.test(str)) return false; return true; }; 

function chkEmail(str) {
    return str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == 0 ? true : false
}